package com.yvon.service.demo.spring.context.support;

import com.yvon.service.demo.spring.beans.factory.support.DefaultListableBeanFactory;
import com.yvon.service.demo.spring.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * xml应用程序上下文抽象类
 *
 * @author : Yvon
 * @since : 2022-12-07
 */
public abstract class AbstractXmlApplicationContext extends AbstractRefreshableApplicationContext{

    @Override
    protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
        // 实例化Bean定义加载器
        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory, this);
        // 获取配置信息地址，并根据地址加载资源
        String[] configLocations = getConfigLocations();
        if (null != configLocations) {
            beanDefinitionReader.loadBeanDefinitions(configLocations);
        }
    }

    /**
     * 获取配置信息位置
     *
     * @return {@code String[] }
     */
    protected abstract String[] getConfigLocations();
}
